package w4156.idog.client;


import java.util.List;

import w4156.idog.exception.AuthenticationException;
import w4156.idog.exception.DBexception;
import w4156.idog.model.Card;
import w4156.idog.model.User;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.ServiceDefTarget;

public interface TestGWT extends RemoteService {
	
	public String testEBJ() throws AuthenticationException;
	
	public User authenticate(String username, String password) throws AuthenticationException;
	public void logout() throws AuthenticationException;
	public void createUser(User user) throws AuthenticationException, DBexception;
	public void deleteUser(User user) throws AuthenticationException, DBexception;
	public void modifyUser(User user) throws AuthenticationException, DBexception;

	/**
	 * @reference http://en.wikipedia.org/wiki/Blackjack
     * @return the current player lists in particular table
     */
    public List<User> getUserList() throws AuthenticationException;

    /**
     * Notify server I am ready.
     */
    public void setReady() throws AuthenticationException;
    
    /**
     * USER status:
     * PENDING: initial status when user joined the table
     * READY: when user clicks "READY"
     * MY_TURN: user's turn to play
     * BID: 
     * HIT:
     * STAND:
     * WIN:
     * LOSE:
     */
    
    public void joinTable() throws AuthenticationException;
    /**
     * Bid the money 
     * @param money
     * @return the card
     */
    public Card bid(double money) throws AuthenticationException;   
    
    /*
     * Take no more card
     */
    public void stand() throws AuthenticationException;
    
    /*
     * Take another card
     * @return the drew card
     */
    public Card hit() throws AuthenticationException;
    
    public Card doubledown() throws AuthenticationException;
    
    public void surrender() throws AuthenticationException;
    //public void Card doubledown(User user) throws AuthenticationException;
	
    /**
     * Given user id, return the card suit in that user
     */
    public List<Card> getCardList(int userId) throws AuthenticationException;
    
	public static class Util {
		private static TestGWTAsync instance;
		public static TestGWTAsync getInstance(){
			if (instance == null) {
				instance = (TestGWTAsync) GWT.create(TestGWT.class);
				ServiceDefTarget target = (ServiceDefTarget) instance;
				target.setServiceEntryPoint(GWT.getModuleBaseURL() + "TestGWT");
			}
			return instance;
		}
	}
}
